using System.Data;
using UnityEngine;

public class TestSql : MonoBehaviour
{
    public string host = "localhost";//服务器地址
    public string port = "3306";//端口号
    public string username = "root";//用户名
    public string pwd = "123456";//密码
    public string database = "my_db_01";//数据库名称
    SqlAccess sql;
    void Start()
    {
        sql = new SqlAccess(host, port, username, pwd, database);

        string[] items = { "name" };//字段名
        string[] col = { };
        string[] op = { };
        string[] val = { };
        DataSet ds = sql.SelectWhere("student", items, col, op, val);//替换表名test

        if (ds != null)
        {
            DataTable table = ds.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                string str = "";
                foreach (DataColumn column in table.Columns)
                    str += row[column] + " ";
                Debug.Log(str);
            }
        }
    }

    private void OnDisable()
    {
        sql.Close();
    }
}
